package com.nit.jap.jdbc;

import lombok.SneakyThrows;
import org.junit.Test;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;

/**
 * @author :fjw
 * @description:TODO
 * @date :2020/10/17 14:26
 */
public class JdbcTest {

	private String driver;

	private String url;

	private String username;

	private String password;

	@SneakyThrows
	@Test
	public void test() {
		InputStream is = JdbcTest.class.getClassLoader().getResourceAsStream("application.properties");
		Properties properties = new Properties();
		properties.load(is);
		url=properties.getProperty("spring.datasource.url");
		username="root";
		password="root";
		Connection connection = DriverManager.getConnection(url, username, password);
		PreparedStatement preparedStatement = connection.prepareStatement("select  * from sys_dept where dept_id = ?");
		preparedStatement.setString(1,"17");
		ResultSet resultSet = preparedStatement.executeQuery();
		while (resultSet.next()) {
			System.out.println(resultSet.getString("name"));
		}
	}

}
